package net.bxx2004.cp.commands.subs;

import net.bxx2004.cp.CloudPlugin;
import net.bxx2004.pandalib.pcommands.PSubcommands;
import net.bxx2004.pandalib.planguage.PMessage;
import net.bxx2004.pandalib.putil.PPlugin;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

import java.io.File;

public class InfoPluginCommand extends PSubcommands {
    @Override
    public String getName() {
        return "info <Name>";
    }

    @Override
    public String getDescription() {
        return "查询某插件详情";
    }

    @Override
    public boolean performCommand(CommandSender commandSender, String[] strings) {
        if (strings.length >= 0){
            if (strings[0].equalsIgnoreCase("info")){
                Player player = (Player) commandSender;
                if (player.hasPermission("cp.use")){
                    if (strings.length < 2 && strings[0].equalsIgnoreCase("info")){
                        PMessage.to(player,"&c请输入参数...");
                    }else {
                        if (!CloudPlugin.plugins.keySet().contains(strings[1])){
                            PMessage.to(player,"&c没有载入这个插件...");
                            return false;
                        }
                        if (!CloudPlugin.plugins.get(strings[1])){
                            PMessage.to(player,"&c这个插件已被停用...");
                            return false;
                        }else {
                            PMessage.toList(player,PPlugin.getPluginInfo(strings[1]));
                        }
                    }
                }else {
                    PMessage.to(player, "&c你没有权限...");
                }
            }
        }
        return false;
    }
}
